#include <algorithm>
#include <cctype>
#include <set>
#include <string>
#include <vector>

using namespace std;

/** This class is used to make validations in the input equations.
 */
class SimpleValidator {
 public:

  /** Simple constructor. */
  SimpleValidator() : equation_("") {}

  /** This types represent format codes for validation.
   */
  enum FormatCodeValue {
    Correct,  /**< Format is Ok. */
    NumberOrVariableBadFormat,  /**< There is an issue in the numbers or
                                     variables, for example something like
                                     "3+ 2.02 14=1", "3.42.3+5=1", or "y3+2=1"
                                 */
    SignsBadFormat,  /**< Problem with the signs, for example "24+3+=1"
                          or "+3+5=1", or "4++4=1" */
    UnrecognizedCharacter,  /**< Unrecognized character, as for example "3+,=1"
                             */
    EmptyEquation,  /**< The equation is empty (""). */
    OtherError
  };

  /** Mapping from error code to a corresponding error message.
   */
  const static string mapping[6];

  /** This method validates an equation from the input.
   *
   * @return A code value representing a bad format issue.
   */ 
  FormatCodeValue DoValidation();

  /** equation setter.
   *  @param equation the equation to store in the object.
   */
  void set_equation(string equation) { equation_ = equation; }
  /** equation getter.
   *  @return string stored in the object.
   */
  string equation() { return equation_; }

 private:
  bool CheckEmptyEquation();
  bool CheckUnrecognizedCharacter();
  bool CheckNumberOrVariableBadFormat();
  bool CheckSignsBadFormat();

  string equation_;
};
